       subroutine run_rhf_ri(icore, isympopa, isympopb, 
     &                       isymvrta, isymvrtb,
     &                       isymmo, nvmax, nomax, nmo, icrsiz)
c    
      use mod_ri 
      use mod_symm
      use mod_iop
      use mod_orbit
      use mod_size
      use mod_ioff
      implicit none
      integer*8, intent(in) :: nmo, nvmax, nomax, isymmo(nmo, 8)
      integer*8, intent(in) :: icrsiz
      integer*8, intent(in) :: isymvrta(nvmax,8), isymvrtb(nvmax,8)
      integer*8, intent(in) :: isympopa(nomax,8), isympopb(nomax,8)
      real*8, intent(in) :: icore(icrsiz)
      double precision dtmp
c
      integer*8 maxcor, iintfp, iflags
c
      double precision eccsd, escf, scalfact, tmp
      double precision, allocatable::ea(:), eb(:)
c
      integer*8 :: ncycle, a, b
c
      integer*8:: nbasis, nsol, nbas2, no2, nv2, no4, nv2o2
      integer*8:: iread, isox, isoy, isoz, itmp1, itmp2, imoc, norbs
      integer*8:: iaopop(8), irrep, i, j, nsize, idx, ioffa
      integer*8:: irrepab, irrepcd, irrepc, irrepd
c            
      integer*8:: iijkl, iiabj, iabij, iijka
      integer*8:: nv3, nv3o, i0, i1, i2, i3, iend, nvt
      integer*8:: icontl, nabcdab, numab, numcd, naux8t(8)
      integer*8:: maxcor1, istat, irrepmo(nmo), ioffmo(nmo)
      integer*8:: c, d, numc, numd, irrepci, numi, irrepi
      integer*8:: numab1, numab2, numab3, numcd1, numcd2, numcd3
      integer*8:: vstart, nfirst, nread, nleft, idx2, nsize2
      double precision tt1, tt2,rt1, rt2, rt3, rt4, rt5, rt6 
      double precision tt11, tt12, tt13
      real*8 :: tmpmat(nmo, nmo), tmp1

      integer, allocatable :: isymnaux(:,:)
      real*8, allocatable :: fijaar(:,:), fijaai(:,:)
      real*8, allocatable :: fijabr(:,:), fijabi(:,:)
      real*8, allocatable :: fiaaar(:,:), fiaaai(:,:)
      real*8, allocatable :: fiaabr(:,:), fiaabi(:,:)
      real*8, allocatable :: fabaar(:,:), fabaai(:,:)
      real*8, allocatable :: fababr(:,:), fababi(:,:)
      real*8, allocatable :: fijr(:,:), fiji(:,:)
      real*8, allocatable :: fiar(:,:), fiai(:,:)
      real*8, allocatable :: fabr(:,:), fabi(:,:)
C     real*8, allocatable :: iaam(:,:,:), ibbm(:,:,:)
      real*8, allocatable :: rivv(:), rivo(:), rioo(:)
      real*8, allocatable :: rivv2(:), rivo2(:), rioo2(:)
      real*8, allocatable :: rivvtmp(:)
      real*8, allocatable :: ea_resort(:), eb_resort(:)
C
      character*12 string2, sfname
      logical :: lsoineom, lscalar, lbdf, lscalsoc
C     
      integer*8 memsize, rec_char, n, k, nvv, nvo, noo
      integer*8 fcstar, nbas, nocca, noccb, nirreptmp
      integer*8, external :: idsymsz, irpdso, isymoffso, idsymsoc
      double precision, external :: dnrm2, nrm2so

      call walltimeso(tt1)
      zorb(1) = 1
      zorb(2:8) = 0
      naux8t(1:8) = 0
      open(44, file='dfpar.data', form='formatted')
      read(44, *) naux, n, n
      do i = 1, nirrep
         read(44, *) naux8t(i)
         naux8(i) = naux8t(i)
      enddo
      close(44)
Cwf   open(44, file='eri_df_aa', form='unformatted')
Cwf   read(44) naux, n, n 
      if(ldebug) then 
         write(6,*)'naux', naux, n, n
      endif
Cwf   write(6, *) 'size of iaam(Gb):', naux*n*n*8/(1024*1024*1024)
Cwf   allocate(iaam(naux,n,n), STAT = istat)
Cwf   call checkalloc(istat, 'iaam in run_rhf_ri')
      if (n/=nmo) then
          write(6,*) 'error!'
          stop
      endif
      allocate(isymnaux(naux, 8), STAT = istat)
Cwf   read(44) (((iaam(i,j,k),i=1, naux),j=1,n),k=1,n)
Cwf   close(44)
Cwf   tmp1 = 0.d0
Cwf   write(6,*) 'nmo, n', naux, nmo, n, n*n
Cwf   do i = 1, naux
Cwf      call pyscfio_split('cd_c', 'eri_mo', tmpmat, i, 1, n*n)
Cwf      call dcopy(n*n, tmpmat, 1, iaam(i,1,1), naux)
Cwf      do j = 1, n
Cwf      do k = 1, n
Cwf         tmp1 = max(tmp1, dabs(iaam(i,j,k) - tmpmat(j,k)))
Cwf      enddo
Cwf      enddo
Cwf   enddo
Cwf   write(6,*) 'difference:', tmp1
      idx = 0  
      do n = 1, nmo 
         do irrep = 1, nirrep
         do i = 1, pop(irrep,1)+vrt(irrep,1)
            if(isymmo(i, irrep)==n) then 
               idx = idx + 1
               irrepmo(n) = irrep
               ioffmo(n) = i 
            endif
         enddo
         enddo
      enddo
Cwf   naux8 = naux 
Cwf   if(ldebug) then 
Cwf      write(6,*)'norm of iaam', naux*nmo*nmo, nrm2so(naux*nmo*nmo, iaam, 1)
Cwf   endif
!
      call walltimeso(tt11)
      write(6,*) 'wall time for read (L|pq)', tt11-tt1
      call flush(6)
!     idx = 1
!     do b = 1, nva
!     do a = 1, nva 
!        do n = 1, naux 
!            icore(idx)=iaam(n,a+noa,b+noa)
!            idx = idx + 1
!        enddo
!     enddo
!     enddo
!     nsize = nva*nva*naux 
!     write(6,*)'norm of rivv', nsize, nrm2so(nsize, icore, 1)
Cwf   naux8t=0
Cwf   call ri_symm(iaam, nmo, isymmo, isymnaux, naux8t)
!
Cwf   naux8t(1:8) = naux
      do j = 1, 8
      do i = 1, naux
         isymnaux(i,j) = i
      enddo
      enddo
!
      nvv = idsymsoc(1, naux8, zorb, 1, vrta, vrta, 1) 
      nvo = idsymsoc(1, naux8, zorb, 1, vrta, popa, 1)
      noo = idsymsoc(1, naux8, zorb, 1, popa, popa, 1)
!
      write(6, '(1x, a, f6.2)') 'size of rivv(Gb):',
     &                          dble(nvv*8.d0/(1024*1024*1024))
      write(6, '(1x, a, f6.2)') 'size of rivo(Gb):',
     &                          dble(nvo*8.d0/(1024*1024*1024))
      write(6, '(1x, a, f6.2)') 'size of rioo(Gb):',
     &                          dble(noo*8.d0/(1024*1024*1024))
!
      allocate(rivv(nvv), rivo(nvo), rioo(noo), STAT = istat)
      call checkalloc(istat, 'rivv ... in run_rhf_ri')
!
      call ri_resort_symm(rivv, rivo, rioo, icore, nmo, isymnaux, 
     &                isymvrta, isympopa, nvmax, nomax, naux8t, icrsiz)
      if(ldebug) then 
         nsize = idsymsoc(1, naux8t, zorb, 1, vrta, vrta, 1) 
         write(6,*)'norm of rivv', nsize, nrm2so(nsize, rivv, 1)
         nsize = idsymsoc(1, naux8t, zorb, 1, vrta, popa, 1) 
         write(6,*)'norm of rivo', nsize, nrm2so(nsize, rivo, 1)
         nsize = idsymsoc(1, naux8t, zorb, 1, popa, popa, 1) 
         write(6,*)'norm of rioo', nsize, nrm2so(nsize, rioo, 1)
      endif
!
!     deallocate(iaam, STAT = istat)
!     call checkalloc(istat, 'dealloc iaam in run_rhf_ri')
!
      allocate(rivo2(nvo), STAT = istat)
      call checkalloc(istat, 'rivo2 ... in run_rhf_ri')
!     call VmnpqVmnrs_to_Vpqrs(rivv, rivv, 1, 1, naux8t, zorb, 1, 
!    &                vrta, vrta, 1, vrta, vrta, 1, icore, 1, 1.d0,0.d0)
!     nsize = idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1) 
!     write(6,*)'norm of nvvvv', nsize, nrm2so(nsize, icore, 1)
!     i1 = 1  + idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1) 
!     i2 = i1 + idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1)
!
      call walltimeso(tt12)
      write(6,*) 'wall time for symmetrize (L|pq)', tt12-tt11
      call flush(6)
!
      if (eri_level==0) then
      allocate(rivv2(nvv), STAT = istat)
      call checkalloc(istat, 'rivv2 ... in run_rhf_ri')
      call sstgenso(rivv, rivv2, nsize, naux8t, zorb, vrta, vrta, 
     &             icore, 1, '1324') 
      endif
      naux8(1:8) = naux8t(1:8)
      call sstgenso(rivo, rivo2, nsize, naux8t, zorb, vrt, pop, 
     &                                  icore, 1, '1324')
!     call getri_vvvv(icore, icore(i1), rivv, rivv2, icore(i2),
!    &              isymvrta, nvmax)
!     nsize = idsymsoc(1, vrta, vrta, 0, vrta, vrta, 0) 
!     write(6,*)'norm of IABCDAA', nrm2so(nsize, icore, 1)
!     nsize = idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1) 
!     write(6,*)'norm of IABCDAB', nrm2so(nsize, icore(i1), 1)

      call clmoioso0(1, icore, naux8t, zorb, 1, vrt, vrt, 1, 'RIVV____')
      call clmoioso0(1, icore, naux8t, zorb, 1, vrt, pop, 1, 'RIVO____')
      call clmoioso0(1, icore, naux8t, zorb, 1, pop, pop, 1, 'RIOO____')
      call putallso(rivv, 1, 'RIVV____') 
      call putallso(rivo, 1, 'RIVO____') 
      call putallso(rioo, 1, 'RIOO____')
      open(44, file='naux8', form='formatted')
      write(44,*) naux8t 
      close(44)
      naux8 = naux8t
      call walltimeso(tt2)
      write(6,*)'wall_time for initio------', tt2-tt1
      call walltimeso(tt1)
!-------for ABAB
3000  call clmoioso0(1, icore, pop(1,1), pop(1,1), 1, 
     &                        pop(1,1), vrt(1,1), 1, 'IJKAAB__')
!     write(6,*)'pop and vrt', pop(:,1)
!     write(6,*)'pop and vrt', vrt(:,1) 
      call clmoioso0(1, icore, vrt(1,1), pop(1,2), 1, 
     &                       vrt(1,1), pop(1,2), 1, 'BIAJABAB')
      call clmoioso0(1, icore, vrt(1,2), pop(1,1), 1, 
     &                       vrt(1,2), pop(1,1), 1, 'BIAJAAAA')
      call clmoioso0(1, icore, vrt(1,1), pop(1,1), 1, 
     &                       vrt(1,2), pop(1,2), 1, 'BIAJAABB')


      call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 1, 
     &                      pop(1,1), pop(1,2), 1, 'ABIJAB__')

      call clmoioso0(1, icore, pop(1,1), pop(1,2), 1, 
     &                      pop(1,1), pop(1,2), 1, 'IJKLAB__')
      call walltimeso(tt2)
      write(6,*)'wall time for small-------', tt2-tt1
      call walltimeso(tt1)
!     call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 1, 
!    &                     vrt(1,1), vrt(1,2), 1, 'ABCDAB__')
!     call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 0, 
!    &                     vrt(1,1), vrt(1,2), 0, 'ABCDAA__')
      call walltimeso(tt2)
!      write(6,*)'Cpu_time for abcd', tt2-tt1
      call walltimeso(tt1)
    
!      write(6,*)'finished clmoioso'
      i0 = 1
      i1 = i0 + nmo**3
      i2 = i1 + nmo**3
!      write(6,*)'pop', pop(:,1), pop(:,2)
!     do i = 1, nmo
!         nirreptmp = nirrep 
!         nirrep = 1
!         call VmnpqVmnrs_to_Vpqrs(iaam, iaam((i-1)*nmo*naux+1), 1, 1,
!    &                 naux, zorb, 1, nmo,
!    &                 nmo, 1, nmo, zorb, 1, icore(i0), 1, 1.d0, 0.d0)  
!         nirrep = nirreptmp
!          write(6,*)'nmo', i
!         call mopy2mo_rhf(icore(i0), icore(i1), nmo, 
!    &                  ioffmo(i), irrepmo(i), isymmo, isympopa,
!    &                  isympopb, isymvrta, isymvrtb, nomax, nvmax)
!     enddo
!      write(6,*)'finished mopy2mo!', naux8t
!=====for vvvo
      if(ldebug) then 
         write(6,*)'nirrep', nirrep
         nsize = idsymsoc(1, naux8t, zorb, 1, vrta, vrta, 1) 
         write(6,*)'norm of rivv', nsize, nrm2so(nsize, rivv, 1)
         nsize = idsymsoc(1, naux8t, zorb, 1, vrta, popa, 1) 
         write(6,*)'norm of rivo', nsize, nrm2so(nsize, rivo, 1)
      endif
      if(eri_level==0.or.eri_level==1) then 
         call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 1, 
     &                     vrt(1,1), pop(1,2), 1, 'ABCIAB__')
         call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 0,
     &                     vrt(1,1), pop(1,2), 1, 'ABCIAA__')
         i0 = 1
         do irrepi = 1, nirrep
            i1 = i0 + isd*idsymsoc(irrepi, zorb, vrta, 1, vrta, vrta, 1)
            numi = popa(irrepi) 
            do i = 1, numi 
               call getpqrvo_ri(icore(i0), i, irrepi, rivv, rivo2, 1)
               call iassymso(icore(i0), icore(i1), irrepi, vrta, vrta,
     &                       vrta, zorb, 5)
               call putpqrso(icore(i0), i, irrepi, 1, 'ABCIAB__')
               call putpqrso(icore(i1), i, irrepi, 1, 'ABCIAA__')
            enddo
         enddo
      endif
      if(ldebug.and.eri_level/=2) then
         call VmnpqVmnrs_to_Vpqrs(rivv, rivo, 1, 1, naux8t, zorb, 1, 
     &                vrta, vrta, 1, vrta, popa, 1, icore, 1, 1.d0,0.d0)
         nsize = idsymsoc(1, vrta, vrta, 1, vrta, popa, 1)
         call sstgenso(icore, icore(nsize+1), nsize, vrta, vrta,vrta,popa, 
     &             icore, 1, '1324') 
         call getallso(icore, 1, 'ABCIAB__') 
         write(6,*)'norm of ABCIAB 1', nsize, nrm2so(nsize, icore,1)
         write(6,*)'norm of ABCIAB 2', nsize, nrm2so(nsize, icore(nsize+1),1)
         call putallso(icore(nsize+1), 1, 'ABCIAB__')
      endif
      call walltimeso(tt11)
      write(6,*) 'wall time for saving ABCIAB and ABCIAA ', tt11-tt1
      call flush(6)
!=====for vvoo
      call VmnpqVmnrs_to_Vpqrs(rivo, rivo, 1, 1, naux8t, zorb, 1, 
     &                vrta, popa, 1, vrta, popa, 1, icore, 1, 1.d0,0.d0)
      nsize = idsymsoc(1, vrta, popa, 1, vrta, popa, 1)
      call sstgenso(icore, icore(nsize+1), nsize, vrta, popa,vrta,popa, 
     &             icore, 1, '1324') 
      if(ldebug) then 
         write(6,*)'norm of ABIJAB', nsize, nrm2so(nsize, icore(nsize+1),1)
      endif
      call putallso(icore(nsize+1), 1, 'ABIJAB__')
!=====for ooov
      call VmnpqVmnrs_to_Vpqrs(rioo, rivo, 1, 1, naux8t, zorb, 1, 
     &                popa, popa, 1, vrta, popa, 1, icore, 1, 1.d0,0.d0)
      nsize = idsymsoc(1, popa, popa, 1, vrta, popa, 1)
      call sstgenso(icore, icore(nsize+1), nsize, popa, popa,vrta,popa, 
     &             icore, 1, '2413') 
      if(ldebug) then 
         write(6,*)'norm of IJKAAB', nsize, nrm2so(nsize, icore(nsize+1),1)
      endif
      call putallso(icore(nsize+1), 1, 'IJKAAB__')
!=====for oooo
      call VmnpqVmnrs_to_Vpqrs(rioo, rioo, 1, 1, naux8t, zorb, 1, 
     &                popa, popa, 1, popa, popa, 1, icore, 1, 1.d0,0.d0)
      nsize = idsymsoc(1, popa, popa, 1, popa, popa, 1)
      call sstgenso(icore, icore(nsize+1), nsize, popa, popa,popa,popa, 
     &             icore, 1, '1324') 
      if(ldebug) then 
         write(6,*)'norm of IJKLAB', nsize, nrm2so(nsize, icore(nsize+1),1)
      endif
      call putallso(icore(nsize+1), 1, 'IJKLAB__')
!=====<IA||BJ>=(ib|aj)-(ab|ij)  ! saved as BIAJ
      nsize = idsymsoc(1, vrta, popa, 1, vrta, popa, 1) 
      i1 = 1 + nsize
      i2 = i1 + nsize
!-----<Ia||Bj>=(BI|Aj)        ! saved as BIaj 
      call VmnpqVmnrs_to_Vpqrs(rivo, rivo, 1, 1, naux8t, zorb, 1, 
     &                vrta, popa, 1, vrta, popa, 1, icore, 1, 1.d0,0.d0)
!     call myicopyso(icore, icore(i1), nsize)
!     call scalso(nsize, -1.d0, icore(i1), 1
      if(ldebug) then
         write(6,*)'norm of BIAJAABB', nsize, nrm2so(nsize, icore,1)
      endif
      call putallso(icore, 1, 'BIAJAABB')
!-----<Ia||bJ>=-(IJ|ab)        ! saved as BiAj 
      call VmnpqVmnrs_to_Vpqrs(rivv, rioo, 1, 1, naux8t, zorb, 1, 
     &                vrta, vrta, 1, popa, popa, 1, icore(i1), 1, 1.d0,0.d0)
      call sstgenso(icore(i1), icore(i2), nsize, vrta,vrta,popa,popa, 
     &             icore, 1, '2314')
      call scalso(nsize, -1.d0, icore(i2), 1) 
      if(ldebug) then 
        write(6,*)'norm of BIAJABAB', nsize, nrm2so(nsize, icore(i2),1)
      endif
      call putallso(icore(i2), 1, 'BIAJABAB')
      call axpyso(nsize,  1.d0, icore(i2), 1, icore, 1)
      if(ldebug) then 
          write(6,*)'norm of BIAJAAAA', nsize, nrm2so(nsize, icore,1)
      endif
      call putallso(icore, 1, 'BIAJAAAA')
      call walltimeso(tt2)
      write(6,*)'cpu_time for small calc--', tt2-tt1
      call walltimeso(tt1)
!====VVVV
!      write(6,*)'naux8', naux8, naux8t
      nsize = idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1)
      i1 = 1
      i2 = i1 + idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1)
      i3 = i2 + idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1)
      if(eri_level==0) then
         call clmoioso0(1, icore, vrt(1,1), vrt(1,2), 1,
     &                     vrt(1,1), vrt(1,2), 1, 'ABCDAB__')
         do irrepi = 1, nirrep
            numi = vrta(irrepi)
            do i = 1, numi
               call getpqrvv_ri(icore, i, irrepi, rivv, rivv2, 1)
!               write(6,*)'i', i
               call putpqrso(icore, i, irrepi, 1, 'ABCDAB__')
            enddo
         enddo
      endif

!     call clmoioso0(1, icore, vrta, vrta, 0, vrta, vrta, 0, 'ABCDAB1_')
!     call clmoioso0(1, icore, vrta, vrta, 2, vrta, vrta, 2, 'ABCDAB2_')
!     call VmnpqVmnrs_to_Vpqrs(rivv, rivv, 1, 1, naux8t, zorb, 1, 
!    &                vrta, vrta, 1, vrta, vrta, 1, icore(i1), 1, 1.d0,0.d0)
!     nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test  ', dnrm2(nsize, icore(i1), 1)
!     call sstgenso(icore(i1), icore(i2), nsize, vrta,vrta,vrta,vrta, 
!    &             icore, 1, '1324')
!     nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test  ', dnrm2(nsize, icore(i2), 1)
!     call vvvv_half(icore(i2), 0.5d0)
!     nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test  ', dnrm2(nsize, icore(i2), 1)
!     call iassymso(icore(i2), icore(i1), 1, vrta, vrta, vrta, vrta, 5)
!     nsize = idsymsoc(1,vrta,vrtb,0 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test  ', dnrm2(nsize, icore(i1), 1)
!     call icompso(icore(i1), icore(i3), vrta, vrta, 0, 1, 
!    &              vrta, vrta,1, 0, 1)
!     call putallso(icore(i3), 1, 'ABCDAB1_') 
!     nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test 5 ', dnrm2(nsize, icore(i2), 1)
!     call isymtrso(icore(i2), icore(i1), vrta, vrta, 1, 1, vrta, vrta,
!    &                     1, 0, 1)
!     nsize = idsymsoc(1, vrta, vrta, 1, vrta, vrta, 1)
!     call axpyso(nsize, 1.d0, icore(i1), 1, icore(i2), 1)
!     nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
!     write(6,*)'norm of ABCD test 5 ', dnrm2(nsize, icore(i2), 1)
!     call icompsovv(icore(i2), icore(i1), 0.5d0)
!     nsize = idsymsoc(1,vrta,vrtb,2 ,vrta,vrtb, 2)
!     write(6,*)'norm of ABCD test 6 ', dnrm2(nsize, icore(i1), 1)
!     call putallso(icore(i1), 1, 'ABCDAB2_') 
!     call icompso(icore(i2), icore(i1), vrta, vrta, 1, 2, 
!    &                       vrta, vrta, 1, 1, 1)
!     call icompso(icore(i1), icore(i2), vrta, vrta, 2, 1, 
!    &                       vrta, vrta, 1, 2, 1)
!     nsize = idsymsoc(1,vrta,vrtb,2 ,vrta,vrtb, 2)
!     write(6,*)'norm of ABCD test 6 ', dnrm2(nsize, icore(i2), 1)
!     call vvvv_half2(icore(i2), 0.5d0) 
!     write(6,*)'norm of ABCD test 6 ', dnrm2(nsize, icore(i2), 1)
!     call putallso(icore(i2), 1, 'ABCDAB2_') 
      
!     call getri_vvvv_io(rivv, rivv2, icore,
!    &              isymvrta, nvmax)
      call walltimeso(tt2)
!     write(6,*)'cpu_time for large calc', tt2-tt1
      if(ldebug) then
      call walltimeso(tt1)
      call getallso(icore, 1, 'IJKLAB__')
      nsize = idsymsoc(1, popa, popb, 1, popa, popb, 1)
      write(6,*)'norm of IJKLAB  ',nsize, dnrm2(nsize, icore, 1)

      call getallso(icore, 1, 'IJKAAB__')
      nsize = idsymsoc(1, popa, popb, 1, popa, vrtb, 1)
      write(6,*)'norm of IJKAAB  ',nsize, dnrm2(nsize, icore, 1)

      call getallso(icore, 1, 'ABIJAB__')
      nsize = idsymsoc(1, vrta,vrtb,1,popa,popb, 1)
      write(6,*)'norm of ABIJAB  ',nsize, dnrm2(nsize, icore, 1)

      call getallso(icore, 1, 'BIAJAABB')
      nsize = idsymsoc(1, vrta,popa,1,vrtb,popb, 1)
      write(6,*)'norm of BIAJAABB',nsize, dnrm2(nsize, icore, 1)

      call getallso(icore, 1, 'BIAJABAB')
      nsize = idsymsoc(1,vrta,popb,1, vrta, popb,1)
      write(6,*)'norm of BIAJABAB',nsize, dnrm2(nsize, icore, 1)

      call getallso(icore, 1, 'BIAJAAAA')
      nsize = idsymsoc(1,vrtb,popa, 1,vrtb, popa,1)
      write(6,*)'norm of BIAJAAAA',nsize, dnrm2(nsize, icore, 1)

      if(eri_level==0.or.eri_level==1) then
         call getallso(icore, 1, 'ABCIAB__')
         nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,popb, 1)
         write(6,*)'norm of ABCIAB  ',nsize, dnrm2(nsize, icore, 1)
      endif
      if(eri_level==0) then
         call getallso(icore, 1, 'ABCDAB__')
         nsize = idsymsoc(1,vrta,vrtb,1 ,vrta,vrtb, 1)
         write(6,*)'norm of ABCDAB  ',nsize, dnrm2(nsize, icore, 1)
      endif
!     call getallso(icore, 1, 'ABCDAB1_')
!     nsize = idsymsoc(1,vrta,vrtb,0 ,vrta,vrtb, 0)
!     write(6,*)'norm of ABCDAB1  ', dnrm2(nsize, icore, 1)

!     call getallso(icore, 1, 'ABCDAB2_')
!     nsize = idsymsoc(1,vrta,vrtb,2 ,vrta,vrtb, 2)
!     write(6,*)'norm of ABCDAB2  ', dnrm2(nsize, icore, 1)

      endif
!     call walltimeso(tt2)
!     write(6,*)'cpu_time for bench', tt2-tt1
cc---------
      if(ldebug) then 
         write(6,*)'finished cc_inter'
      endif
      return
      end



